package com.caac.core.web.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.caac.core.Global;
import com.caac.core.util.HttpUtils;
import com.caac.core.web.form.BaseForm;
import org.apache.struts.action.ActionMapping;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright caac 2004</p>
 * <p>Company: caac</p>
 * @author <a href="mailto:project@caac.com.cn">Project Group</a>
 * @version 1.0
 */

public abstract class BasePageViewAction extends BasePageAction {
    protected final PageForward doPageExecute(ActionMapping mapping,
                                              BaseForm form,
                                              HttpServletRequest request,
                                              HttpServletResponse response,
                                              int pageNo,
                                              int pageSize) throws Exception {
    	
        PageViewForward pvf = doPageViewExecute(mapping, form, request,
                                                response, pageNo, pageSize);
        if(request.getAttribute("orderstr")==null){
        	request.setAttribute("orderstr", "");
        	request.setAttribute("orderflag", 0);
        }
        HttpUtils.setAttribute(request, Global.KEY_VIEW_PROPS, pvf.getViewProps());
        HttpUtils.setAttribute(request, Global.KEY_VIEW_NAME, pvf.getViewName());
        HttpUtils.setAttribute(request, Global.KEY_ORDER_NAME, pvf.getOrderName());
       return new PageForward(pvf.getForward(), pvf.getData(), pvf.getPage());
    }

    protected abstract PageViewForward doPageViewExecute(ActionMapping mapping,
            BaseForm form,
            HttpServletRequest request,
            HttpServletResponse response,
            int pageNo,
            int pageSize) throws Exception;
}
